package com.itheima.controller;


import com.itheima.domain.entity.Requirement;
import com.itheima.service.RequirementService;
import com.itheima.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.util.List;

@RestController
@Api(tags = "需求相关的接口")
@RequestMapping("/requirement")
@Slf4j
public class RequirementController {
    @Autowired
    private RequirementService requirementService;

    /**
     * 获取前50的技术需求
     * @return
     */
    @GetMapping("/total/top50")
    @ApiOperation("获取全部岗位前50的技术需求")
    public Result<List<Requirement>> top50(){
       List<Requirement> result= requirementService.top50();
       return Result.success(result);
    }

    /**
     * 获取岗位前20的技术需求
     * @param category
     * @return
     */
    @GetMapping("/category/top20")
    @ApiOperation("获取岗位前20的技术需求")
    public Result<List<Requirement>> top20(String category) throws SQLException {
        log.info("category={}", category);
        List<Requirement> result=requirementService.top20(category);
        return Result.success(result);
    }
}
